function toJSON (obj,...keys){
    //console.log(obj);
    //console.log(keys);
    if(typeof obj=="object"){
        if(keys.length==0) return JSON.stringify(obj);
        let json={};
        for(let i=0;i<keys.length;i++){
            let key=keys[i];
            let t=typeof obj[key];
            //if(typeof obj == 'boolean')
            if(["string","number","boolean"].includes(t)){
                json[key]=obj[key]
            }
        }
        return JSON.stringify(json)
    }
}

/**
 * 获取元素的位置
 * @param {Element} el
 * @returns {{top: number, left: number, width: number, height: number}}
 */
function getElementRect(el){
    let rect={left:el.offsetLeft,top:el.offsetTop,width:el.offsetWidth,height:el.offsetHeight};
    console.log(el)
    do{
        el=el.offsetParent;
        if(el==null) return rect;
        rect.left+=el.offsetLeft;
        rect.top+=el.offsetTop
    }while (el!=document.body)
    return rect;
}

export default {toJSON,getElementRect}
